package com.sml.mapper;

import com.sml.pojo.Article;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface ArticleMapper {

    /**
     * 新增文章
     *
     * @param article 文章对象
     */
    @Insert("INSERT INTO article (title, content, cover_img, state,category_id, create_time, update_time,create_user) " +
            "VALUES (#{title}, #{content}, #{coverImg}, #{state},#{categoryId}, #{createTime}, #{updateTime},#{createUser})")
    void add(Article article);

    /**
     * 分页查询文章列表
     *
     * @param userId     用户id
     * @param categoryId 文章分类id
     * @param state      文章状态
     * @return 文章列表
     */
    List<Article> list(Integer userId, Integer categoryId, String state);
}
